import http from "@/assets/js/http";
import { getApiBaseUrl } from "@/assets/js/utils";

/**
 * 获取动态配置的物料
 * @param {String} key 多渠道后台-动态配置中设置的key
 * @returns {Object}
 */
export const getDynamicData = (key) =>
  new Promise((resolve, reject) => {
    const url = `${getApiBaseUrl().dynamicConfig}/v1.0/bizdict/dict/key`;

    http
      .get(url, {
        params: {
          merchantCode: "1001",
          serverId: "1001",
          channel: "h5",
          dictKey: key,
        },
      })
      .then((res) => {
        const { data } = res;
        resolve(data);
      })
      .catch(() => {
        reject("程序开小差了，请稍后再试");
      });
  });
